package com.ruixinzheng.logicdemo;

import java.io.IOException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

public class PracticeDemo {

    public void genericType() {
        ArrayList<? extends IOException> list = new ArrayList<>();
        //list.add(new IOException());

        try {
            Method method = ArrayList.class.getDeclaredMethod("add", Object.class);
            method.invoke(list, new Integer(15));
        } catch (Exception e) {
            e.printStackTrace();
        }

        for (int i = 0; i < list.size(); i++) {
            Object obj = list.get(i);
            System.out.println(i + " " + obj.getClass().getName() + " " + obj);
        }
    }
}
